<template>
  <div class="app-container">
      <el-form ref="form" :model="form" :rules="rules" >
          <el-form-item label="编号:" prop="number">
              <el-input  v-model="form.numberNum" disabled style="width: 280px;"/>
          </el-form-item>
          <el-form-item label="项目名称" prop="projectName">
              <el-select v-model="form.projectName"
                         :disabled="form.projectName&&title!='添加出差申请'"
                         placeholder="请选择" clearable>
                  <el-option
                      v-for="item in projectNameList"
                      :key="item.projectName"
                      :label="item.projectName"
                      :value="item.projectName"
                  ></el-option>
              </el-select>
          </el-form-item>
              <el-form-item label="应聘岗位" prop="position">
                  <el-input v-model="form.position" :disabled='isdisabled' placeholder="请输入应聘岗位" />
              </el-form-item>
              <el-form-item label="离岗所需时间" prop="departureTime">
                  <el-input v-model="form.departureTime" :disabled='isdisabled' placeholder="请输入离岗所需时间" />
              </el-form-item>
              <el-form-item label="获取岗位渠道" prop="channel">
                  <el-input v-model="form.channel" :disabled='isdisabled' placeholder="请输入获取岗位渠道" />
              </el-form-item>
              <el-form-item label="推荐人姓名" prop="referee">
                  <el-input v-model="form.referee" :disabled='isdisabled' placeholder="请输入推荐人姓名" />
              </el-form-item>
              <el-form-item label="姓名" prop="name">
                  <el-input v-model="form.name" :disabled='isdisabled' placeholder="请输入姓名" />
              </el-form-item>
              <el-form-item label="出生年月" prop="birthDate">
                  <el-date-picker clearable
                                  v-model="form.birthDate"
                                  type="datetime"
                                  :disabled='isdisabled'
                                  value-format="yyyy-MM-dd HH:mm:ss"
                                  placeholder="请选择出生年月">
                  </el-date-picker>
              </el-form-item>
              <el-form-item label="民族" prop="nation">
                  <el-input v-model="form.nation" :disabled='isdisabled' placeholder="请输入民族" />
              </el-form-item>
              <el-form-item label="籍贯" prop="nativePlace">
                  <el-input v-model="form.nativePlace" :disabled='isdisabled' placeholder="请输入籍贯" />
              </el-form-item>
              <el-form-item label="家庭所在地" prop="homeLocation">
                  <el-input v-model="form.homeLocation" :disabled='isdisabled' placeholder="请输入家庭所在地" />
              </el-form-item>
              <el-form-item label="身份证号" prop="idNumber">
                  <el-input v-model="form.idNumber" :disabled='isdisabled' placeholder="请输入身份证号" />
              </el-form-item>
              <el-form-item label="政治面貌" prop="politicalOutlook">
                  <el-input v-model="form.politicalOutlook" :disabled='isdisabled' placeholder="请输入政治面貌" />
              </el-form-item>
              <el-form-item label="技术职称" prop="technicalTitle">
                  <el-input v-model="form.technicalTitle" :disabled='isdisabled' placeholder="请输入技术职称" />
              </el-form-item>
              <el-form-item label="手机号码" prop="phone">
                  <el-input v-model="form.phone" :disabled='isdisabled' placeholder="请输入手机号码" />
              </el-form-item>
              <el-form-item label="邮箱" prop="email">
                  <el-input v-model="form.email" :disabled='isdisabled' placeholder="请输入邮箱" />
              </el-form-item>
              <el-form-item label="身份证地址" prop="address">
                  <el-input v-model="form.address" :disabled='isdisabled' placeholder="请输入身份证地址" />
              </el-form-item>
              <el-form-item label="通讯地址" prop="mailAddress">
                  <el-input v-model="form.mailAddress" :disabled='isdisabled' placeholder="请输入通讯地址" />
              </el-form-item>
              <el-form-item label="紧急联系人姓名" prop="emergencyName">
                  <el-input v-model="form.emergencyName" :disabled='isdisabled' placeholder="请输入紧急联系人姓名" />
              </el-form-item>
              <el-form-item label="紧急联系人关系" prop="emergencyRelation">
                  <el-input v-model="form.emergencyRelation" :disabled='isdisabled' placeholder="请输入紧急联系人关系" />
              </el-form-item>
              <el-form-item label="紧急联系人电话" prop="emergencyPhone">
                  <el-input v-model="form.emergencyPhone" :disabled='isdisabled' placeholder="请输入紧急联系人电话" />
              </el-form-item>
              <el-form-item label="教育经历" prop="educationalExperience">
                  <el-input :disabled='isdisabled' v-model="form.educationalExperience" type="textarea" placeholder="请输入内容" />
              </el-form-item>
              <el-form-item label="工作经历" prop="workExperience">
                  <el-input :disabled='isdisabled' v-model="form.workExperience" type="textarea" placeholder="请输入内容" />
              </el-form-item>
              <el-form-item label="是否犯罪" prop="isCrime">
                  <el-input v-model="form.isCrime" :disabled='isdisabled' placeholder="请输入是否犯罪" />
              </el-form-item>
              <el-form-item label="犯罪记录" prop="crimeExperience">
                  <el-input v-model="form.crimeExperience" :disabled='isdisabled' placeholder="请输入犯罪记录" />
              </el-form-item>
              <el-form-item label="是否违纪" prop="isViolation">
                  <el-input v-model="form.isViolation" :disabled='isdisabled' placeholder="请输入是否违纪" />
              </el-form-item>
              <el-form-item label="违纪记录" prop="violationExperience">
                  <el-input v-model="form.violationExperience" :disabled='isdisabled' placeholder="请输入违纪记录" />
              </el-form-item>
              <el-form-item label="是否入院" prop="isHospital">
                  <el-input v-model="form.isHospital" :disabled='isdisabled' placeholder="请输入是否入院" />
              </el-form-item>
              <el-form-item label="住院记录" prop="hospitalExperience">
                  <el-input v-model="form.hospitalExperience" :disabled='isdisabled' placeholder="请输入住院记录" />
              </el-form-item>
              <el-form-item label="是否曾经入职" prop="isEntry">
                  <el-input v-model="form.isEntry" :disabled='isdisabled' placeholder="请输入是否曾经入职" />
              </el-form-item>
              <el-form-item label="曾经入职记录" prop="entryExperience">
                  <el-input v-model="form.entryExperience" :disabled='isdisabled' placeholder="请输入曾经入职记录" />
              </el-form-item>
              <el-form-item label="其他补充说明" prop="otherExperience">
                  <el-input v-model="form.otherExperience" :disabled='isdisabled' placeholder="请输入其他补充说明" />
              </el-form-item>
      </el-form>
      <div v-show="parentTaskId==null" class="dialog-footer" style="text-align:center">
          <el-button :loading="buttonLoading" size="small" type="info" @click="submitCallback">关闭</el-button>
          <el-button :loading="buttonLoading" size="small" type="primary" @click="submitForm" v-if="confirmVisible">提交</el-button>
      </div>
      <!-- 工作流开始 -->
      <verify ref="verifyRef" :taskId="taskId" @submitCallback="submitCallback"
              :taskVariables="taskVariables" :sendMessage="sendMessage"></verify>
  </div>
</template>

<script>
import { getInfo } from "@/api/oa/employeeInfo";
import verify from "@/components/Process/Verify";
import {parseTime} from "@/utils/ruoyi";
export default {
  name: "InfoForm",
  components: {
      verify
  },
  props: {
      businessKey: String, // 业务唯一标识
      parentTaskId: String, // 父级任务id
      taskId: String, // 任务id
      confirmVisible:{
          type: Boolean,
          default: true
      }
  },
  data() {
    return {
      isdisabled:true,
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 表单参数
      form: {},
        projectNameList:[],
      // 表单校验
      rules: {
        position: [
          { required: true, message: "应聘岗位不能为空", trigger: "blur" }
        ],
        departureTime: [
          { required: true, message: "离岗所需时间不能为空", trigger: "blur" }
        ],
        channel: [
          { required: true, message: "获取岗位渠道不能为空", trigger: "blur" }
        ],
        name: [
          { required: true, message: "姓名不能为空", trigger: "blur" }
        ],
        sex: [
          { required: true, message: "性别不能为空", trigger: "change" }
        ],
        birthDate: [
          { required: true, message: "出生年月不能为空", trigger: "blur" }
        ],
        nation: [
          { required: true, message: "民族不能为空", trigger: "blur" }
        ],
        nativePlace: [
          { required: true, message: "籍贯不能为空", trigger: "blur" }
        ],
        homeLocation: [
          { required: true, message: "家庭所在地不能为空", trigger: "blur" }
        ],
        idNumber: [
          { required: true, message: "身份证号不能为空", trigger: "blur" }
        ],
        maritalStatus: [
          { required: true, message: "婚育状况不能为空", trigger: "blur" }
        ],
        politicalOutlook: [
          { required: true, message: "政治面貌不能为空", trigger: "blur" }
        ],
        technicalTitle: [
          { required: true, message: "技术职称不能为空", trigger: "blur" }
        ],
        phone: [
          { required: true, message: "手机号码不能为空", trigger: "blur" }
        ],
        email: [
          { required: true, message: "邮箱不能为空", trigger: "blur" }
        ],
        address: [
          { required: true, message: "身份证地址不能为空", trigger: "blur" }
        ],
        mailAddress: [
          { required: true, message: "通讯地址不能为空", trigger: "blur" }
        ],
        emergencyName: [
          { required: true, message: "紧急联系人姓名不能为空", trigger: "blur" }
        ],
        emergencyRelation: [
          { required: true, message: "紧急联系人关系不能为空", trigger: "blur" }
        ],
        emergencyPhone: [
          { required: true, message: "紧急联系人电话不能为空", trigger: "blur" }
        ],
        educationalExperience: [
          { required: true, message: "教育经历不能为空", trigger: "blur" }
        ],
        workExperience: [
          { required: true, message: "工作经历不能为空", trigger: "blur" }
        ],
        isCrime: [
          { required: true, message: "是否犯罪不能为空", trigger: "blur" }
        ],
        isViolation: [
          { required: true, message: "是否违纪不能为空", trigger: "blur" }
        ],
        isHospital: [
          { required: true, message: "是否入院不能为空", trigger: "blur" }
        ],
        isEntry: [
          { required: true, message: "是否曾经入职不能为空", trigger: "blur" }
        ],
      },
        taskVariables: undefined,
        //消息提醒
        sendMessage: {},
        processKey: 'oa_testDemo',
    };
  },
  watch: {
      businessKey: {
          immediate: true, // 很重要！！！
          handler (newVal) {
              if(newVal) {
                  this.getById()
              }
          }
      }
  },
  methods: {
    submitCallback(){
        this.$emit("closeForm")
    },
    async getById() {
      const {data} = await getInfo(this.businessKey)
      this.form = data;
      if (data.actBusinessStatus.createTime){
            this.form.numberNum=this.processKey + '@' + parseTime(data.actBusinessStatus.createTime, '{y}{m}{d}{h}{i}{s}')
        }
    },
    /** 提交按钮 */
    submitForm() {
        getInfo(this.businessKey).then(response => {
            this.taskVariables = {
                entity: response.data,
            };
            this.sendMessage = {
              title:'单表测试',
                messageContent:'单据【'+this.form.id+"】申请"
            }
        });
        this.$refs.verifyRef.visible = true
        this.$refs.verifyRef.reset()
    },
  }
};
</script>
<style scoped>
    /* 设置滚动条宽度和高度 */
    ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
        width: 8px; /* 横向滚动条 */
        height: 8px; /* 纵向滚动条 必写 */
    }
    /* 设置滚动条样式 */
    ::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
        background-color: #dde;
        border-radius: 3px;
    }
    #selectForm >>> .el-form-item__label {
        font-size: 12px;
    }
    ::v-deep .bjsm .el-form-item__content{
        width: calc(100% - 130px) !important;
    }
</style>
